package xyz.qiquqiu.lc4blogdemo.controller;

import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import reactor.core.publisher.Flux;
import xyz.qiquqiu.lc4blogdemo.aiserverce.DemoService;

@Slf4j
@RestController
@RequiredArgsConstructor
public class ChatController {

    private final DemoService demoService;
    // private final OpenAiChatModel chatModel;

    /**
     * 大模型聊天接口-流式响应
     * @param message 用户发送的消息，相当于提示词prompt
     * @return
     */
    @RequestMapping(value = "/chat", produces = "text/html;charset=utf-8")
    public Flux<String> chat(Long memoryId, String message) {
        log.debug("会话Id={}    用户说：{}", memoryId, message);
        return demoService.chat(memoryId, message);
    }
}
